package cn.bellychang.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @author ChangLiang
 * @date 2019/6/21
 */
@Configuration
public class DataSourceConfig {

    @Bean
    @Qualifier("prodDataSource")
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource.prod")
    public DataSource ProdDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean
    @Qualifier("queryDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.query")
    public DataSource QueryDataSource() {
        return DataSourceBuilder.create().build();
    }
}
